Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R4R: Add tx/encode endpoint and CLI command #3523

Merged
merged 1 commit into from
Feb 8, 2019

Conversation

ducembarr
Copy link
Contributor

This PR adds a /tx/encode endpoint to Gaia to take a JSON-ified transaction, serialize it using the Amino wire format, and return the serialized bytes encoded to a base64 string. The wire format is necessary to determine a transaction's hash, so it's useful for client applications that want to build their own transactions without being dependent on wire serialization changes. I've also included an equivalent gaiacli tx encode command.

  • Targeted PR against correct branch (see CONTRIBUTING.md)

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

    • N/A: Discussed the feature with the Cosmos devs in Slack
  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added entries in PENDING.md with issue #

  • rereviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@jackzampolin
Copy link
Member

This also might be interesting as a microservice...

x/bank/client/cli/encode.go Outdated Show resolved Hide resolved
@@ -0,0 +1,76 @@
package cli
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both this and the rest endpoint should live under the x/auth package. The same applies to the broadcast command/endpoint too, though I reckon we can get this in as it is since such refactoring would be out of context of the PR. /cc @jackzampolin @cwgoes @alexanderbez

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, both should be moved to the auth module. Preferably in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I've moved both to the auth module.

Copy link
Contributor

@alessio alessio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK'd

Copy link
Member

@jackzampolin jackzampolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a significant discussion offline with the SDK team, I don't think this is something we want to have added. cc @cwgoes

@ducembarr
Copy link
Contributor Author

@jackzampolin could you provide a bit more detail on why? Thanks!

@alexanderbez
Copy link
Contributor

@ducembarr we deem that such functionality should not exist in the SDK as it's something we do not intend on maintaining. I believe it would be a great addition as a microservice elsewhere or part of a wallet or block explorer.

Copy link
Member

@jackzampolin jackzampolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a longer discussion this endpoint does have significant utility for users who need to push high volumes of transactions and is a good stopgap until we have amino implementations in other languages

@codecov
Copy link

codecov bot commented Feb 8, 2019

Codecov Report

Merging #3523 into develop will decrease coverage by 0.02%.
The diff coverage is 36.36%.

@@             Coverage Diff             @@
##           develop    #3523      +/-   ##
===========================================
- Coverage    57.12%   57.09%   -0.03%     
===========================================
  Files          190      191       +1     
  Lines        14956    14967      +11     
===========================================
+ Hits          8544     8546       +2     
- Misses        5872     5877       +5     
- Partials       540      544       +4

@jackzampolin jackzampolin changed the title Add tx/encode endpoint and CLI command R4R: Add tx/encode endpoint and CLI command Feb 8, 2019
/tx/encode:
post:
tags:
- ICS20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this from a copy pasta?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ICS20 seemed the most reasonable since it's related to creating and broadcasting transactions.

@@ -0,0 +1,76 @@
package cli
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, both should be moved to the auth module. Preferably in this PR.

x/bank/client/cli/encode.go Outdated Show resolved Hide resolved
Copy link
Contributor

@alessio alessio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few changes are required

@cwgoes
Copy link
Contributor

cwgoes commented Feb 8, 2019

Ref #3560, which can be separate from this PR, but we should definitely do this.

@ducembarr
Copy link
Contributor Author

@alessio @alexanderbez I've responded to PR comments; please re-review. Thanks!

@jackzampolin jackzampolin merged commit 9348750 into cosmos:develop Feb 8, 2019
@zhiyuzhang86
Copy link

zhiyuzhang86 commented Feb 8, 2019

👍 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants